{% extends 'base/nav.html' %}

{% block title %}我的收藏 - 旅游舆情监测{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="page-header">
                <h2><i class="fa fa-heart text-danger"></i> 我的收藏</h2>
                <p class="text-muted">您收藏的旅游景点列表</p>
            </div>

            {% if collections %}
            <div class="row">
                {% for collect in collections %}
                <div class="col-md-4 col-sm-6">
                    <div class="card attraction-card">
                        <img src="{{ collect.attraction.main_image.url }}" class="card-img-top" alt="{{ collect.attraction.name }}" style="height: 200px; object-fit: cover;">
                        <div class="card-body">
                            <h5 class="card-title">
                                <a href="{% url 'main:attraction_detail' collect.attraction.pk %}">
                                    {{ collect.attraction.name }}
                                </a>
                            </h5>
                            <p class="card-text text-muted">
                                <i class="fa fa-map-marker"></i> {{ collect.attraction.location }}
                            </p>
                            <div class="attraction-stats">
                                <span class="badge badge-info">
                                    <i class="fa fa-fire"></i> {{ collect.attraction.heat_index }}
                                </span>
                                <span class="badge badge-success">
                                    <i class="fa fa-comment"></i> {{ collect.attraction.review_count }}
                                </span>
                            </div>
                            {% if collect.notes %}
                            <div class="collect-notes mt-2">
                                <small class="text-muted">
                                    <i class="fa fa-sticky-note"></i> {{ collect.notes }}
                                </small>
                            </div>
                            {% endif %}
                            <div class="collect-actions mt-3">
                                <a href="{% url 'collect:update_collect' collect.pk %}" class="btn btn-sm btn-outline-primary">
                                    <i class="fa fa-edit"></i> 编辑备注
                                </a>
                                <a href="{% url 'collect:delete_collect' collect.pk %}" class="btn btn-sm btn-outline-danger">
                                    <i class="fa fa-trash"></i> 取消收藏
                                </a>
                            </div>
                            <div class="collect-time mt-2">
                                <small class="text-muted">
                                    <i class="fa fa-clock-o"></i> {{ collect.created_at|date:"Y-m-d H:i" }}
                                </small>
                            </div>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>

            <!-- 分页 -->
            {% if is_paginated %}
            <div class="text-center mt-4">
                <nav>
                    <ul class="pagination">
                        {% if page_obj.has_previous %}
                        <li class="page-item">
                            <a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a>
                        </li>
                        {% endif %}

                        {% for num in page_obj.paginator.page_range %}
                        <li class="page-item {% if page_obj.number == num %}active{% endif %}">
                            <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                        </li>
                        {% endfor %}

                        {% if page_obj.has_next %}
                        <li class="page-item">
                            <a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a>
                        </li>
                        {% endif %}
                    </ul>
                </nav>
            </div>
            {% endif %}

            {% else %}
            <div class="text-center py-5">
                <i class="fa fa-heart-o fa-5x text-muted mb-3"></i>
                <h4 class="text-muted">暂无收藏</h4>
                <p class="text-muted">您还没有收藏任何景点</p>
                <a href="{% url 'main:attraction_list' %}" class="btn btn-primary">
                    <i class="fa fa-map-marker"></i> 去发现景点
                </a>
            </div>
            {% endif %}
        </div>
    </div>
</div>

<style>
.attraction-card {
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.attraction-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.attraction-stats .badge {
    margin-right: 5px;
    font-size: 12px;
}

.collect-notes {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}
</style>
{% endblock %}